home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / menu-new.tar / menu-new / menu / signals.c < prev    next >
Text File  |  1993-04-08  |  2KB  |  95 lines

  1. # include <signal.h>
  2. # include "menu.h"
  3.  
  4. /*    PSC MENU COPYRIGHT NOTICE
  5.  
  6.     Part of PSCMenu
  7.  
  8.     This software is to be considered to be public domain, it
  9. may be copied, modified and parts of it may be used in other programs
  10. as long as this copyright notice remains intact.
  11.  
  12.     Copyright()   PSC - Plymouth State College
  13.     Written by:   Ted Wisniewski 12-9-1990
  14.  
  15. */
  16.  
  17. /*
  18.  *    void setup_sigs():
  19.  *
  20.  *    Parameters:    None.
  21.  *
  22.  *    Description:    Set up signal handling.
  23.  *
  24.  *    Returns:    None.
  25.  *
  26.  *    Last Modify:    05-8-91 (TW)
  27.  *
  28.  */
  29.  
  30. void setup_sigs()
  31. {
  32.     /* (void) signal(SIGHUP,catch); */
  33.     /* (void) signal(SIGSEGV,catch); */
  34.     /* (void) signal(SIGBUS,catch); */
  35.     (void) signal(SIGINT,SIG_IGN);
  36.     (void) signal(SIGTSTP,SIG_IGN);
  37.     (void) signal(SIGQUIT,SIG_IGN);
  38. }
  39.  
  40. /*
  41.  *    catch():
  42.  *
  43.  *    Parameters:    signo - The signal ID #.
  44.  *
  45.  *    Description:    Routine to catch specific signals.
  46.  *
  47.  *    Returns:    None.
  48.  *
  49.  *    Last Modify:    05-8-91 (TW)
  50.  *
  51.  */
  52.  
  53. int catch(signo)
  54. int signo;
  55. {
  56.     switch (signo){
  57.        case SIGHUP:
  58.         exit(1);
  59.        break;
  60.        case SIGSEGV:
  61.        /* case SIGBUS: */
  62.         clr_scr();  
  63.             reset_tty();
  64.             end_rev();
  65.         perror(" ");
  66.         exit(1);
  67.        break;
  68.     }
  69. }
  70.  
  71. /*
  72.  *     log_out():
  73.  *
  74.  *    Parameters:    None.
  75.  *
  76.  *    Description:    Kill The process group of the parent to the menu,
  77.  *            hopefully this will be the users login shell.
  78.  *
  79.  *    Returns:    None.
  80.  *
  81.  *    Last Modify:    09-04-91 (TW)
  82.  *
  83.  */
  84.  
  85. void log_out()
  86. {
  87. # ifndef HPUX
  88.     killpg(getppid(),SIGHUP);    /* Kill Parent Process        */
  89.     killpg(getpid(),SIGHUP);    /* Suicide: Kill self.        */
  90. # else
  91.     kill(getppid(),SIGHUP);        /* Kill Parent Process        */
  92.     kill(getpid(),SIGHUP);        /* Suicide: Kill self.        */
  93. # endif HPUX
  94. }
  95.